package com.ecmap.hongyun.commons.utils;

import com.gzym.client.api.ecpark.EcparkUtils;
import com.gzym.client.api.utils.TransData;

/**
 * 
 * @className:SmsUtil.java
 * @classDescription:发送短信工具
 * @author: DANIEL DENG
 * @createTime: 2013-6-5
 *
 */
public class SmsUtil {
	
	private static EcparkUtils ecparkUtils = new EcparkUtils();

	/**
	 * 获取公用包字段（旧交易系统）
	 * @param processCode
	 * @return
	 */
	private static TransData getPublicPackage(String processCode){
		TransData request = new TransData();
		request.setItem("ProcessCode", processCode);
		request.setItem("SystemTrace", "");
		request.setItem("UserAccount", "13751865365");
		request.setItem("UserPassword", "123456");
		request.setItem("ChannelMark", "1");
		request.setItem("ResponseCode", "");
		request.setItem("Reserved", "");
		
		return request;
	}
	
	/**
	 * 发送短信
	 * @param mobileNo 手机号码
	 * @param smsContent 短信内容
	 * @return
	 * @throws Exception
	 */
	public static String sendSms(String mobileNo,String smsContent )throws Exception{
		TransData data = getPublicPackage("XUANWU_SMS_1");
		
		data.setItem("MobileNo", mobileNo);
		data.setItem("SmsContent", smsContent );
		data.setItem("SmsType", "00003");
		
		ecparkUtils.setHostName("219.136.240.43");
		ecparkUtils.setHostPort(18300);
		
		TransData response = ecparkUtils.doRequest(data);
		
		if(ecparkUtils.checkIsSuccess(response)){//请求成功
			//短信发送成功后，缓存验证码
			return "done";
		}else{
			return "fail";
		}
		
	}
}
